const device = require('../util/device');
const logger = require('../util/log')
const audioCodec = require('../lib/audio')

const TAG = 'HELLO';

async function handleHello(socket, request, event) {
    const { audio_params } = event;

    logger.log(TAG, `${device.getReqIP(request)},${device.getReqIDs(request)}, payload: ${JSON.stringify(event)}`)

    const response = {
        type: "hello",
        transport: "websocket",
        audio_params: audioCodec.getAudioParams()
    }

    socket.send(JSON.stringify(response), (err) => {
        if (err) {
            console.log(`[SERVER] error:${err}`);
        }
    })
}

module.exports = {
    handleHello
}